package com.symaster.backups.enumerate;

import lombok.Getter;

import java.awt.*;
import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author yinmiao
 * @version 2024/2/18
 */
@Getter
public enum FileSystemStatus {
    INIT(1, "初始化", new Color(0, 0, 0)),
    BACKUP_IN(2, "正在备份", new Color(0, 0, 0)),
    COMPLETE(3, "备份正常", new Color(64, 158, 255)),
    STOP(4, "已停止", new Color(219, 92, 92)),
    ;

    private final int code;
    private final String label;
    private final Color color;
    private static final Map<Integer, FileSystemStatus> byCode;

    static {
        byCode = Arrays.stream(FileSystemStatus.values()).collect(Collectors.toMap(FileSystemStatus::getCode, e -> e));
    }

    FileSystemStatus(int code, String label, Color color) {
        this.code = code;
        this.label = label;
        this.color = color;
    }

    public static FileSystemStatus ofCode(int code) {
        return byCode.get(code);
    }
}
